package com.hyc.controller;

import com.hyc.SignUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.TreeMap;

@RestController
public class LoginController {

    @RequestMapping("login")
    public String login(String name, String pass, String timestamp, String sign){
        TreeMap<String, Object> param = new TreeMap<>();
        param.put("name",name);
        param.put("pass",pass);
        param.put("timestamp", timestamp);
        String signStr = SignUtil.sign(param, "123456");
        if (sign.equals(signStr)) {
            return "login success";
        } else {
            return "login failed";
        }
    }
}
